# 初始化城市信息
city = {
    "资源": {
        "木材": 100,
        "石头": 100,
        "金币": 100
    },
    "建筑": {
        "房屋": 0,
        "商店": 0,
        "工厂": 0
    }
}

# 建筑建造所需资源
construction_costs = {
    "房屋": {
        "木材": 20,
        "石头": 10,
        "金币": 10
    },
    "商店": {
        "木材": 30,
        "石头": 20,
        "金币": 20
    },
    "工厂": {
        "木材": 50,
        "石头": 40,
        "金币": 30
    }
}

# 显示城市状态
def show_city_status():
    print("城市当前状态：")
    print("资源：")
    for resource, amount in city["资源"].items():
        print(f"{resource}: {amount}")
    print("建筑：")
    for building, count in city["建筑"].items():
        print(f"{building}: {count}")

# 建造建筑
def build_building():
    print("可建造的建筑有：")
    for building in construction_costs:
        print(building)
    building_choice = input("请输入要建造的建筑名称（输入 '退出' 结束建造）：")
    if building_choice == "退出":
        return
    if building_choice not in construction_costs:
        print("没有这种建筑，无法建造。")
        return
    cost = construction_costs[building_choice]
    can_build = True
    for resource, amount in cost.items():
        if city["资源"][resource] < amount:
            can_build = False
            print(f"资源不足，缺少 {resource}，无法建造 {building_choice}。")
            break
    if can_build:
        for resource, amount in cost.items():
            city["资源"][resource] -= amount
        city["建筑"][building_choice] += 1
        print(f"成功建造 {building_choice}！")

# 资源生产
def produce_resources():
    # 简单模拟资源生产，每种建筑有不同的资源产出
    city["资源"]["木材"] += city["建筑"]["房屋"] * 5
    city["资源"]["石头"] += city["建筑"]["商店"] * 3
    city["资源"]["金币"] += city["建筑"]["工厂"] * 10
    print("资源生产完成，当前资源已更新。")

# 主游戏循环
while True:
    show_city_status()
    print("\n请选择操作：")
    print("1. 建造建筑")
    print("2. 生产资源")
    print("3. 结束游戏")
    choice = input("请输入选项编号：")
    if choice == "1":
        build_building()
    elif choice == "2":
        produce_resources()
    elif choice == "3":
        print("游戏结束，感谢你的参与！")
        break
    else:
        print("无效的选项，请重新输入。")